<template>
<!--<todolist></todolist>-->
  {{user.username}}
  <button type="button" @click="handleClick">按钮</button>
</template>

<script >

// import todolist from "@/components/todolist"
import {mapMutations, mapState} from "vuex";

export default {
  name:'todolist',
  data(){
    return{
      // user:this.$store.state.user
    }
  },
  computed: {
    ...mapState(['user'])
  },
  // {
  //   getUser(){
  //     return this.$store.state.user
  //   }
  // },
 methods:{
      ...mapMutations(['setUser']),
      // this.$store.state.user.username = 'root'
      // this.$store.commit('setUser',{
      //   username: 'lisi',
      //   password: '1234'
      // })
   handleClick(){
        this.setUser({
          username: 'lisi'
        })
    }
  }
}

</script>


<style>

</style>